package kr.hkit.powerjava.chapter24;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;

public class CopyfileReader {
	public static void main(String[] args) {
		FileReader fr = null;
		FileWriter fw = null;
		try {
			fr =new FileReader("input.txt");
			fw = new FileWriter("output2.txt");
			int c;
			while( (c=fr.read()) !=-1){
				System.out.printf("%s",(char)c);
				fw.write(c);
			}
		} catch (FileNotFoundException e) {
			System.err.format("%s%n","파일이 존재하지 않음.");
		} catch(Exception e){
			e.printStackTrace();
		} finally{
			if(fr !=null){
				try{fr.close();}catch(Exception e){}
			}
			if(fw !=null){
				try{fw.close();}catch(Exception e){}
			}
		}
	}
}
